﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;

namespace DCTAccess.Business.Location
{
    public class Location
    {
        private int _locationID = -1;
        private string _locationName = string.Empty;
        private string _locationAlias = string.Empty;
        private bool _isEnable = false;
        private int _parentID = -1;

        public int LocationID
        {
            get { return _locationID; }
            set { _locationID = value; }
        }       

        public string LocationName
        {
            get { return _locationName; }
            set { _locationName = value; }
        }
        
        public string LocationAlias
        {
            get { return _locationAlias; }
            set { _locationAlias = value; }
        }
        
        public bool IsEnable
        {
            get { return _isEnable; }
            set { _isEnable = value; }
        }
               
        public int ParentID
        {
            get { return _parentID; }
            set { _parentID = value; }
        }

        public Location() { }

        public Location(DataRow dtLocation)
        {
            this.LocationID = Convert.ToInt32(dtLocation["LocationID"].ToString());
            this.LocationName = dtLocation["LocationName"].ToString();
            this.LocationAlias = dtLocation["LocationAlias"].ToString();  
          
            try
            {
                this.ParentID = Convert.ToInt32(dtLocation["ParentID"].ToString());            
            }
            catch 
            {
                this.ParentID = 0;
            }            

            try
            {
                this.IsEnable = Convert.ToBoolean(dtLocation["IsEnable"].ToString());
            }
            catch
            {
                this.IsEnable = false;
            }            
        }

    }
}
